package com.sxbbc.common.core.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sxbbc.common.core.entity.jz.CPointDetail;
import com.sxbbc.common.core.enums.HandleTypeEnums;
import com.sxbbc.common.core.mapper.jz.CPointDetailMapper;
import com.sxbbc.common.core.service.ICPointDetailService;
import com.sxbbc.common.core.utils.BasePage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 用户积分明细表 服务实现类
 * </p>
 *
 * @author leehao
 * @since 2019-05-07
 */
@Service
public class CPointDetailServiceImpl extends ServiceImpl<CPointDetailMapper, CPointDetail> implements ICPointDetailService {

    @Autowired
    private CPointDetailMapper pointDetailsMapper;

    @Override
    public IPage<CPointDetail> queryCustomerPointList(BasePage<CPointDetail> pageOne, CPointDetail detail) {
        IPage<CPointDetail> list = pointDetailsMapper.queryCustomerPointList(pageOne,detail);
        /*if (pageOne.isPaging()) {
            list = pointDetailsMapper.queryCustomerPointList(pageOne,detail);
        }else{
            list = pointDetailsMapper.queryCustomerPointList(null,detail);
        }*/
        for (CPointDetail p : list.getRecords()) {
            p.setTypeName(HandleTypeEnums.getName(p.getTypeId()));
            p.setCid(null);
        }
        return list;
    }

    @Override
    public CPointDetail selectCustomerLastPoint(Integer cid) {
        return pointDetailsMapper.selectCustomerLastPoint(cid);
    }
}
